﻿using UnityEngine;
using System.Collections;

public class cclSelf : MonoBehaviour {
    private Vector2 left=new Vector2(600f,300f);
    private Vector2 right = new Vector2(-600f, 300f);

    bool isAwake = false;

    private Vector3 showMe = -Vector3.forward;
    public void moveAndDescory() 
    {
        isAwake = true;
        rigidbody2D.isKinematic = false;
        showMe.x = transform.position.x;
        showMe.y = transform.position.y;
        transform.position = showMe;
        if (manCCL.isLeft)
        {

            rigidbody2D.AddForce(left);
        }
        else
        {
            rigidbody2D.AddForce(right);
        }
       
        StartCoroutine(destoryDelly());
    }
    void Update() 
    {
        if (isAwake)
        {
            if (manCCL.isLeft)
            {
                transform.Rotate(300f * Vector3.forward * Time.deltaTime);
            }
            else
            {
                transform.Rotate(-300f * Vector3.forward * Time.deltaTime);
            }
            
        }
    }
    IEnumerator destoryDelly() 
    {
        yield return new WaitForSeconds(1f);
        Destroy(gameObject);
    }
}
